package com.youpai.platform.wallet.service.convert;

import com.youpai.platform.wallet.service.entity.po.WalletRecordPO;
import com.youpai.platform.wallet.web.entity.dto.WalletLogDTO;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @date: 2023/2/18
 * @author: Welles
 * @version: 1.0
 * @description: 钱包转换类
 */
public class WalletConverter {

    public static List<WalletLogDTO> convertWalletLogPO2WalletLogDTO(List<WalletRecordPO> walletRecordPOList) {
        if (CollectionUtils.isEmpty(walletRecordPOList)) {
            return Collections.emptyList();
        }
        List<WalletLogDTO> resultList = new ArrayList<>(walletRecordPOList.size());
        for (WalletRecordPO walletRecordPO : walletRecordPOList) {
            resultList.add(convertWalletLog2WalletLogDTO(walletRecordPO));
        }
        return resultList;
    }

    public static WalletLogDTO convertWalletLog2WalletLogDTO(WalletRecordPO walletRecordPO) {
        if (null == walletRecordPO) {
            return null;
        }
        return new WalletLogDTO()
                .setUid(walletRecordPO.getUid())
                .setWalletId(walletRecordPO.getWalletId())
                .setChangeCoin(walletRecordPO.getChangeCoin())
                .setSource(walletRecordPO.getChangeSource());
    }
}
